<%@ page import="java.util.ArrayList"%>
<%@ page import="com.alpha.bom.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Practice Exams Page</title>
</head>
<body>
	<c:set var="user" value="${sessionScope.user}"></c:set>
	<c:set var="exams" value="${requestScope.exams}"></c:set>
	<c:set var="professors" value="${requestScope.professors}"></c:set>
	
	<div id="header"><%@ include file="Header.jsp"%></div>
	
	
	
	<div id="content">
	
	<c:choose>
		<c:when test="${not empty user}">
			<div id="navbar"><%@ include file="NavigationBar.jsp"%></div>
			<div id="main">
		</c:when>
		<c:otherwise>
			<div id="alluser">
		</c:otherwise>
	</c:choose>
		
		<div class="box">
			<div class="box-header well">
				<h2><i class=" icon-list-alt"></i> Practice Exams</h2>
			</div>
			<div class="box-content">
				<table class="table table-striped table-bordered bootstrap-datatable datatable">
					<thead>
						<tr>
							<th>Exam Name</th>
							<th>Exam Category</th>
							<th>Created By</th>
							<th>Number of Items</th>
							<th>Action</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach var="exam" items="${exams}">
							<tr>
							<td>${exam.examName}</td>
							<td>${exam.category}</td>
							<td>
								<c:forEach var="professor" items="${professors}">
									<c:if test="${professor.userId eq exam.professorId}">
										<c:out value="${professor.firstName}"></c:out> <c:out value="${professor.lastName}"></c:out>
									</c:if>
								</c:forEach>
							</td>
							<td><c:out value="${exam.getQuestions().size()}"></c:out></td>
							<td><a class="btn btn-success" href="TakeExamServlet?exam_id=${exam.examId}"><i class="icon-edit"></i> Take Exam</a></td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
			</div>
		</div>
		
		<br/>
		<c:if test="${empty user }">
			<center>
			<a class="btn" href="Login.jsp"><i class="icon-user"></i> Back to Login Page</a><br/>	
			</center>		
		</c:if>
		
		<c:if test="${not empty user}">
			</div>
		</c:if>
	
	</div>
</body>
</html>